home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / SciAn / src / ScianPointers.c < prev    next >
C/C++ Source or Header  |  1994-08-01  |  1KB  |  56 lines

  1. /*ScianPointers.c
  2.   Eric Pepke
  3.   8 August 1993
  4.  
  5.   Pointers in SciAn.  A pointer is a variable that just contains an address.
  6.   SciAn doesn't pay any attention to the address; it's for use with system-
  7.   specific things, like function pointers or file pointers.
  8. */
  9.  
  10. #include "Scian.h"
  11. #include "ScianTypes.h"
  12. #include "ScianErrors.h"
  13. #include "ScianPointers.h"
  14.  
  15. typedef struct
  16.     {
  17.     Thing    thing;        /* flags and stuff */
  18.     void    *pointer;    /* the actual pointer*/
  19.     } Pointer;
  20.  
  21. #ifdef PROTO
  22. ObjPtr NewPointer(void *p)
  23. #else
  24. ObjPtr NewPointer(p)
  25. void *p;
  26. #endif
  27. /*Creates a new pointer given p*/
  28. {
  29.     Pointer *retVal;
  30.  
  31.     retVal = (Pointer *) NewObject(NULLOBJ, sizeof(Pointer) - sizeof(Obj));
  32.     if (!retVal)
  33.     {
  34.         OMErr();
  35.         return NULLOBJ;
  36.     }
  37.     retVal -> thing . flags = OT_POINTER;
  38.     retVal -> pointer = p;
  39.     return (ObjPtr) retVal;
  40. }
  41.  
  42. #ifdef PROTO
  43. void *GetPointer(ObjPtr pointer)
  44. #else
  45. void *GetPointer(pointer)
  46. ObjPtr pointer;
  47. #endif
  48. {
  49.     if (!pointer || !IsPointer(pointer))
  50.     {
  51.     ReportError("GetPointer", "Not a pointer");
  52.         return 0;
  53.     }
  54.     return ((Pointer *) pointer) -> pointer;
  55. }
  56.